﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyThongTinNhanKhau.GUI
{
    public partial class TMNhanKhau : Form
    {
        GUI.HoKhau hoKhauGUI;
        static String maHoKhau;
        static String maNhanKhauStatic;
        model.BO.TMNhanKhauBO tmNhanKhauBO;

        public TMNhanKhau(GUI.HoKhau hoKhau, String mHK, String mNK)
        {
            this.hoKhauGUI = hoKhau;
            maHoKhau = mHK;
            maNhanKhauStatic = mNK;
            InitializeComponent();
        }

        private void TMNhanKhau_Load(object sender, EventArgs e)
        {
            tmNhanKhauBO = new model.BO.TMNhanKhauBO(this, hoKhauGUI);
            comboBoxQHCH.SelectedIndex = 0;

            tmNhanKhauBO.loadFindTable("All");
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            tmNhanKhauBO.btnTimKiem();
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            tbFindMaNhanKhau.Text = "";
            tbFindTenNhanKhau.Text = "";
        }

        private void gridView2_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            tbMaNhanKhau.Text = this.gridViewNhanKhau.GetRowCellValue(this.gridViewNhanKhau.FocusedRowHandle, "MaNhanKhau").ToString();
            tbTenNhanKhau.Text = this.gridViewNhanKhau.GetRowCellValue(this.gridViewNhanKhau.FocusedRowHandle, "HoTen").ToString();
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            tmNhanKhauBO.btnLuu(maHoKhau);
        }
    }
}
